using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.IO;

namespace SUnit.Gui
{
    class Program
    {
#if MONO
#else
		[DllImport("user32.dll")]
		static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
#endif

		/// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Borramos la carpeta de archivos temporales
            string tempPath = Path.Combine(Application.StartupPath, "Temp");
            try
            {
                if (Directory.Exists(tempPath))
                    Directory.Delete(tempPath, true);
            }
            catch {}

#if MONO
#else
			IntPtr hWnd = Process.GetCurrentProcess().MainWindowHandle;
			ShowWindow(hWnd, 0);
#endif
            
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new SUnitForm());
        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            MessageHelper.Error(string.Format("Error inesperado:\n{0}", e.Exception.ToString()));
        }
    }
}